package com.github.aloxc.plugin.restplus.annotations;

import com.github.aloxc.plugin.DonotGuard;


/**
 *
 * @author leero
 */
public enum MicronautRequestMethodAnnotation {
    /**
     * GET
     */
    @DonotGuard
    GET("io.micronaut.http.annotation.Get", "GET"),

    /**
     *
     */
//    METHOD_MAPPING("io.micronaut.http.annotation.HttpMethodMapping", "METHOD_MAPPING"),

    /**
     * POST
     */
    @DonotGuard
    POST( "io.micronaut.http.annotation.Post", "POST"),

    /**
     * PUT
     */
    @DonotGuard
    PUT( "io.micronaut.http.annotation.Put", "PUT"),

    /**
     * DELETE
     */
    @DonotGuard
    DELETE( "io.micronaut.http.annotation.Delete", "DELETE"),

    /**
     * HEAD
     */
    @DonotGuard
    HEAD( "io.micronaut.http.annotation.Head", "HEAD"),

    /**
     * OPTIONS
     */
    @DonotGuard
    OPTIONS("io.micronaut.http.annotation.Options", "PATCH"),

    /**
     * PATCH
     */
    @DonotGuard
    PATCH("io.micronaut.http.annotation.Patch", "PATCH");
    MicronautRequestMethodAnnotation(String qualifiedName, String methodName) {
        this.qualifiedName = qualifiedName;
        this.methodName = methodName;
    }

    private String qualifiedName;
    private String methodName;

    public String methodName() {
        return this.methodName;
    }

    public String getQualifiedName() {
        return qualifiedName;
    }

    public String getShortName() {
        return qualifiedName.substring(qualifiedName.lastIndexOf(".")-1);
    }

    public static MicronautRequestMethodAnnotation getByQualifiedName(String qualifiedName) {
        for (MicronautRequestMethodAnnotation annotation : MicronautRequestMethodAnnotation.values()) {
            if (annotation.getQualifiedName().equals(qualifiedName)) {
                return annotation;
            }
        }
        return null;
    }
}
